<?php

namespace App\Transformers\User;

use App\Models\UserNotice;
use League\Fractal\TransformerAbstract;

class UserNoticesTransformer extends TransformerAbstract
{
    public function transform(UserNotice $userNotice)
    {
        return [
            'id' => $userNotice->id,
            'user_id'=>$userNotice->user_id ?? '',
            'type'=>$userNotice->type ?? 0,
            'sender_user_id'=>$userNotice->sender_user_id ?? '',
            'title'=>$userNotice->title ?? '',
            'content'=>$userNotice->content ?? '',
            'is_send'=>$userNotice->is_send ?? 1,
            'delete_at'=>$userNotice->delete_at ?? '',
            'created_at' => $userNotice->created_at ? $userNotice->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $userNotice->updated_at ? $userNotice->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }
}
